package com.nervenets.general.entity;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

import java.io.Serializable;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class NumberRange implements Serializable {
    @ApiModelProperty(value = "最小值")
    private Number start;
    @ApiModelProperty(value = "最大值")
    private Number end;

    public boolean in(Number value) {
        return value.doubleValue() >= start.doubleValue() && value.doubleValue() <= end.doubleValue();
    }

    public boolean isValid() {
        return start.doubleValue() > 0 || end.doubleValue() > 0;
    }
}
